package com.jshx.sz.gdjt.control;

import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jshx.sz.gdjt.R;

/**
 * 页面标题头
 * @author xiangchangan
 * @time 2013-08-20
 */
public class TextEditView extends LinearLayout {

	private final static String TAG = "TextEditView";
	
	/**
	 * 标题
	 */
	private TextView title;
	
	/**
	 * 
	 */
	private EditText edit;
	
	/**
	 * 上下文对象
	 */
	private Context context;
	
	public TextEditView(Context context) {
		super(context);
		this.context = context;
	}
	
	public TextEditView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context = context;
	}

	@Override
	protected void onFinishInflate() 
	{
		super.onFinishInflate();
		edit = (EditText)findViewById(R.id.text_edit);
		title = (TextView)findViewById(R.id.text_title);
	}
	
	/**
	 * 设置标题
	 */
	public void setTitle(String text)
	{
		if(title != null && text != null)
		{
			title.setText(text);
		}
	}
	
	/**
	 * 设置内容
	 */
	public void setValue(String text)
	{
		if(text != null && edit != null)
		{
			edit.setText(text);
		}
	}
	
	/**
	 * 设置数据数据类型
	 */
	public void setEditType(int type)
	{
		if(edit != null)
		{
			edit.setInputType(type);
		}
	}
	
	public EditText getEdit() {
		return edit;
	}

	public void setEdit(EditText edit) {
		this.edit = edit;
	}

	/**
	 * 获取输入框中文字
	 * @return
	 */
	public String getEditValue()
	{
		if(edit != null)
		{
			return edit.getText().toString();
		}
		return "";
	}
}
